package com.huaxin.hxcloud.work;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.huaxin.hxcloud.R;
import com.huaxindata.common.base.HxBaseDialogFragment;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @author songxf
 * @date 2018/6/15
 * @Desc SPT 初始化远控设备dialogFragment
 * Copyright HUAXIN DATA. All rights reserved.
 */
public class HxSPTInitTargetFragment extends HxBaseDialogFragment {
    @BindView(R.id.tv_title)
    TextView     mTvTitle;
    @BindView(R.id.cancel_btn)
    Button       mCancelBtn;
    @BindView(R.id.init_btn)
    Button       mInitBtn;
    @BindView(R.id.rl_button)
    LinearLayout mRlButton;
    private onClickedInitLisetener mInitLisetener;

    public void setCancleLisetener(onCancleLisetener cancleLisetener) {
        this.mCancleLisetener = cancleLisetener;
    }

    private onCancleLisetener mCancleLisetener;

    public void setInitLisetener(onClickedInitLisetener initLisetener) {
        this.mInitLisetener = initLisetener;
    }

    public interface onCancleLisetener {
        void cancle();
    }

    public interface onClickedInitLisetener {
        void init();
    }

    public static HxSPTInitTargetFragment newInstance() {

        Bundle args = new Bundle();

        HxSPTInitTargetFragment fragment = new HxSPTInitTargetFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int setRootViewId() {
        return R.layout.dialog_init_target;
    }

    @Override
    public void initData() {

    }

    @Override
    public int showPosition() {
        return Gravity.CENTER;
    }


    @OnClick({R.id.cancel_btn, R.id.init_btn})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cancel_btn:
                if (mCancleLisetener != null) {
                    mCancleLisetener.cancle();
                } else {
                    dismiss();
                }
                break;
            case R.id.init_btn:
                if (mInitLisetener != null) {
                    mInitLisetener.init();
                    dismiss();
                }
                break;
        }
    }
}
